{% extends "base.html" %}
{% load staticfiles  lptstags chartkick  %}
{% block title %}  <title>Results</title>  {% endblock%}
{% block css%}
	{{ block.super }}
	<link rel="stylesheet"  href="{% static "lpts/css/results.css" %}" />
	<link rel="stylesheet"  href="{% static "lpts/css/popup.css" %}" />
{%endblock%}
{% block script%}
	{{block.super}}
	 <script src="{% static  'jquery/1.8.3/jquery.min.js' %}"></script>
	<script src="{% static  'highcharts/4.0.3/highcharts.js' %}"></script>
	<script src="/static/chartkick.js"></script>
{%endblock%}

{% block contents%}
<div id="results" class="resultsdiv">
	<div id="blanket"  style="display:none;"></div>
	<p>Job:  <span style="color:#117837">{{job_object.jobid}} &nbsp;&nbsp; &nbsp; </span>操作系统:  <span style="color:#117837">{{job_object.os}}</span> </p>
	<div id="scenes">
		<li style="list-style-type:square"><h3> 测试方案</h3></li>
		<p><strong>名称:</strong> {{job_object.scenegroup}}</p>
		{% if job_object.scenegroup.descriptions %}
			<p>{{job_object.scenegroup.descriptions}} </p>
		{%else %}
			<p><strong>描述:</strong> N/A</p>
		{%endif%}
		<table class="bordered">
			<tr>
				<th>名称</th>
				<th>测试内容</th>
				<th>测试分类</th>
				<th>测试工具</th>
				<th>并行数</th>
				<th>测试次数</th>
				<th>主要参数</th>
				<th>描述</th>
			</tr>
			{% for scene in job_object.scenegroup|getmtm:"scenes" %}
			<tr>
				<td>{{ scene.name}}</td>
				<td>{{ scene.testcontent}}</td>
				<td>{{ scene.testclass}}</td>
				<td>
					<div id="{{scene.tool}}"  class="popUpDiv"  style="display:none;">
						<table class="bordered">
							<tr>
								<th>名称</th>
								<td>{{scene.tool.name}}</td>
							</tr>
							<tr>
								<th>版本</th>
								<td>{{scene.tool.version}}</td>
							</tr>
							<tr>
								<th>描述</th>
								<td>{{scene.tool.descriptions}}</td>
							</tr>
	
						</table>
						<div style="text-align:center;"><button   href="#" onclick="popup('{{ scene.tool}}')" >关闭</button></div>
					</div>
					 <a href="#" onclick="popup('{{ scene.tool}}')">{{ scene.tool}}</a>
				</td>
				<td>{{ scene.parallels}}</td>
				<td>{{ scene.times}}</td>
				<td>{{ scene.mainparas}}</td>
				<td>{{ scene.descriptions}}</td>
			</tr>
			{% endfor %}
		</table>
		<br style="clear:both;" />
	</div>	
	<div id="environ" > <!-- 显示环境信息，包括硬件环境和系统环境 -->
		<li style="list-style-type:square"><h3> 测试环境</h3></li>
		<li style="list-style-type:circle"><h4>硬件环境</h4></li>
		<div>
			<table class="bordered">
				<tbody>
					<tr>
						<th style="width:100px;">型号</th>
						<td>{{job_object.hardware.name}}</td>
					</tr>
					<tr>
						<th style="width:100px;">CPU</th>
						<td>{{job_object.hardware.cpu}}</td>
					</tr>
					<tr>
						<th style="width:100px;">Memory</th>
						<td>{{job_object.hardware.memory}}</td>
					</tr>
					<tr>
						<th style="width:100px;">磁盘</th>
						<td>{{job_object.hardware.disk}}</td>
					</tr>
					<tr>
						<th style="width:100px;">网络</th>
						<td>{{job_object.hardware.network}}</td>
					</tr>
					<tr>
						<th style="width:100px;">其他</th>
						<td>{{job_object.hardware.others}}</td>
					</tr>
				</tbody>
			</table>
		</div>
		<li style="list-style-type:circle"><h4>系统环境</h4></li>
		{% with environ_obj=job_object.environ  %}
		<div>
			<table class="bordered">
				<tbody>
					<tr>
						<th style="width:100px;">型号</th>
						<td>{{job_object.os}}</td>
					</tr>
					<tr>
						<th style="width:100px;">内核信息</th>
						<td>{{environ_obj.kernel}}</td>
					</tr>
					<tr>
						<th style="width:100px;">启动参数</th>
						<td>{{environ_obj.kernelcmd}}</td>
					</tr>
					<tr>
						<th style="width:100px;">运行方式</th>
						<td>{{environ_obj.runlevel}}</td>
					</tr>
					<tr>
						<th style="width:100px;">文件系统</th>
						<td>{{environ_obj.filesystem}}</td>
					</tr>
					<tr>
						<th style="width:100px;">交换分区</th>
						<td>{{environ_obj.swapsize}}</td>
					</tr>
					<tr>
						<th style="width:100px;">安装包数量</th>
						<td>{{environ_obj.packages}}</td>
					</tr>
					<tr>
						<th style="width:100px;">GCC</th>
						<td>{{environ_obj.gcc}}</td>
					</tr>
					<tr>
						<th style="width:100px;">GLIBC</th>
						<td>{{environ_obj.glibc}}</td>
					</tr>
					<tr>
						<th style="width:100px;">JAVA</th>
						<td>{{environ_obj.java}}</td>
					</tr>
					<tr>
						<th style="width:100px;">SELinux</th>
						<td>{{environ_obj.selinux}}</td>
					</tr>
					<tr>
						<th style="width:100px;">IPTables</th>
						<td>{{environ_obj.iptables}}</td>
					</tr>
					<tr>
						<th style="width:100px;">运行服务</th>
						<td>{{environ_obj.services}}</td>
					</tr>
					<tr>
						<th style="width:100px;">其他</th>
						<td>{{environ_obj.others}}</td>
					</tr>
				</tbody>
			</table>
		</div>
		{%endwith%}
	</div>
		<div id="data">
		<li style="list-style-type:square"><h3>测试数据</h3></li>
		{% for testclass_obj  in testclass_objects %}<!-- 获取测试分类 -->
		{% with result_objects_1=result_objects|filter_by_testclass:testclass_obj %}<!-- 过滤测试分类为testclass_obj的所有result_objects -->
		{% if result_objects_1 %} <!-- 如果以上判断，result_objects_1不为空，继续执行如下操作 -->
			<li  style="list-style-type:circle"><h4>{{testclass_obj.name}}</h4></li>
			<p>&nbsp;&nbsp;&nbsp;&nbsp;{{testclass_obj.descriptions}}</p>
			{% for  testcontent_obj  in   testclass_obj|reversequery:"testcontent_set" %} <!-- 获取testclass_obj的所有测试内容 -->
			{% with result_objects_2=result_objects_1|filter_by_testcontent:testcontent_obj%}
			{% if result_objects_2 %} <!-- 过滤测试内容为testcontent_obj的所有result_objects -->
				<h4>{{forloop.counter}}.  {{ testcontent_obj.name }}</h4>
				<p>&nbsp;&nbsp;&nbsp;&nbsp;{{testcontent_obj.descriptions}}</p>
			{% for scene_obj in testcontent_obj|reversequery:"scene_set"%} <!-- 过滤testcontent_obj对应的所有scene objects -->
			{% with result_objects_3=result_objects_2|filter_by_scene:scene_obj %} <!-- 过滤scene_obj对应的所有result objects -->
			{% if result_objects_3 %}
				<div id="{{scene_obj.name}}"  class="popUpDiv" style="display:none;">
					<table class="bordered">
					<tr>
						<th>名称</th>
						<td>{{ scene_obj.name}}</td>
					</tr>
					<tr>
						<th>测试内容</th>
						<td>{{ scene_obj.testcontent}}</td>
					</tr>
					<tr>
						<th>测试分类</th>
						<td>{{ scene_obj.testclass}}</td>
					</tr>
					<tr>
						<th>测试工具</th>
						<td>{{ scene_obj.tool}}</td>
					</tr>
						<th>并行数</th>
						<td>{{ scene_obj.parallels}}</td>
					</tr>
					<tr>
						<th>测试次数</th>
						<td>{{ scene_obj.times}}</td>
					</tr>
					<tr>
						<th>主要参数</th>
						<td>{{ scene_obj.mainparas}}</td>
					</tr>
					<tr>
						<th>描述</th>
						<td>{{ scene_obj.descriptions}}</td>
					</tr>
				</table>
				<div style="text-align:center;"><button   href="#"  onclick="popup('{{scene_obj.name}}')" >关闭</button></div>
			</div>
			<h4>{{forloop.parentloop.counter}}.{{forloop.counter}}. <a href="#" onclick="popup('{{scene_obj.name}}')">{{scene_obj.name}}</a></h4>
				<table class="bordered">
					<tr>
						<th></th>
						<th>并行数</th>
						<th>平均值</th>
						<th>标准方差</th>
						<th>历史最小值</th>
						<th>历史最大值</th>
						<th>历史平均值</th>
					</tr>
					{% for index_dic  in result_objects_3|index %} <!-- 获取所有评价指标, index_dic形式为{"index", "copy"} -->
					{% for result_obj  in result_objects_3|querysetfilter:index_dic|order_by:"parallel" %}  <!-- 过滤指标 index_dic的所有result_objs -->
					<tr >
						{% if forloop.first %}
						<td style="text-align:center;" rowspan={{ result_objects_3|querysetfilter:index_dic|length|add:1}}>
							<div id="{{result_obj.index}}"  class="popUpDiv"  style="display:none;">
								<table class="bordered">
										<tr>
											<th>名称</th>
											<td>{{result_obj.index.name}}</td>
										</tr>
										<tr>
											<th>单位</th>
											<td>{{result_obj.index.unit}}</td>
										</tr>
										<tr>
											<th>评价标准</th>
											<td>{{result_obj.index.measure}}</td>
										</tr>
										<tr>
											<th>测试工具</th>
											<td>{{result_obj.index.tool}}</td>
										</tr>
										<tr>
											<th>描述</th>
											<td>{{result_obj.index.descriptions}}</td>
										</tr>
									</table>
								<br style="clear:both;" />
								<div style="text-align:center;"><button   href="#" onclick="popup('{{result_obj.index}}')" >关闭</button></div>
							</div>
							<a href="#" onclick="popup('{{ result_obj.index}}')">{{result_obj.index}}</a>
						</td>
						{%endif%}
						<td  >{{result_obj.parallel}}</td>
						<td >{{result_obj|mmms|key:"value__avg"|floatformat}} {{result_obj.index.unit}}</td>
						<td>N/A  {{result_obj.index.unit}}</td>
						{% with history_value_objects=value_objects|filter_by_index:result_obj.index|filter_by_parallel:result_obj.parallel  %}
						<td>{{ history_value_objects|mmm|key:"value__min"|floatformat}}  {{result_obj.index.unit}}</td>
						<td>{{ history_value_objects|mmm|key:"value__max"|floatformat}}  {{result_obj.index.unit}}</td>
						<td>{{ history_value_objects|mmm|key:"value__avg"|floatformat}}  {{result_obj.index.unit}}</td>
						{% endwith%}
					</tr>
					{%endfor%}
					<tr>
						<td colspan=6>
						{%  get_data result_objects_3|querysetfilter:index_dic|order_by:"parallel"   as resultdata %}
							<div id="{{result_obj}_chart"  style="text-align:center;">
								{% column_chart  resultdata  %}
							</div>
		
						</td>
					</tr>
					{%endfor%}
					</tbody>
				</table>
				{%endif%}
				{%endwith%}
				{% endfor %}
				<br style="clear:both;" />
			{%endif%}
			{%endwith%}
			{% endfor %}
		{%endif%}
		{%endwith%}
		{% empty %}
			<p>空。</p>
		{% endfor %}
	<br style="clear:both;" />
	</div>
	<br style="clear:both;" />
</div>
{% endblock %}